package util;

public class Movie {
    public static final String NULL_POINT = "N/A";
    public static final String MOVIE_FORMAT = "%-15.15s %-10s %-20s %-10s";
    private String name;
    private String year;
    private String director;
    private int rating;
    private int id;
    private static final String movieTable = String.format(MOVIE_FORMAT, "Movie", "Year", "director", "Rating");

    public Movie(int id, String name, String year, String director) {
        this.id = id;
        this.name = name;
        this.year = year;
        this.director = director;
    }

    public Movie(int id, String name, String year, String director, int rating) {
        this(id, name, year, director);
        this.rating = rating;
    }

    public static String getMovieTable() {
        return movieTable;
    }

    @Override
    public String toString() {
        String ratingStr = rating == 0 ? NULL_POINT : Integer.toString(rating);
        return String.format(MOVIE_FORMAT, name, year, director, ratingStr);
    }


    public String getName() {
        return name;
    }

    @Override
    public boolean equals(Object object) {
        Movie movie = (Movie) object;
        return toString().equals(movie.toString());
    }

    public int getId() {
        return id;
    }
}
